package cn.orangeframe.neon.infrastructure.repository;

import cn.orangeframe.neon.domain.adapter.MetadataAdapter;
import cn.orangeframe.neon.domain.entity.WorkflowDef;
import cn.orangeframe.neon.domain.entity.GraphData;
import cn.orangeframe.neon.infrastructure.repository.mapper.MetadataMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MysqlMetadataAdapter implements MetadataAdapter {

    private final MetadataMapper mapper;

    public MysqlMetadataAdapter(MetadataMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public List<WorkflowDef> getAllWorkflowDef() {
        return mapper.getAllWorkflowDef();
    }

    @Override
    public WorkflowDef getWorkflowDef(String name, int version) {
        return mapper.getWorkflowDef(name, version);
    }

    @Override
    public Integer getLatestVersion(String name) {
        return mapper.getLatestVersion(name);
    }

    @Override
    public Integer updateWorkflowDef(WorkflowDef def, int latestVersion, String json_data) {
        return mapper.updateWorkflowDef(def, latestVersion, json_data);
    }

    @Override
    public Integer registerWorkflowDef(WorkflowDef def, int latestVersion, String json_data) {
        return mapper.registerWorkflowDef(def, latestVersion, json_data);
    }

    @Override
    public GraphData getGraphWorkflowDef(String name, int version) {
        return mapper.getGraphWorkflowDef(name, version);
    }

    @Override
    public Integer getGraphLatestVersion(String name) {
        return mapper.getGraphLatestVersion(name);
    }


    @Override
    public Integer registerGraphWorkflowDef(GraphData def, int latestVersion, String json_data) {
        return mapper.registerGraphWorkflowDef(def, latestVersion, json_data);
    }

    @Override
    public Integer updateGraphWorkflowDef(GraphData def, int latestVersion, String json_data) {
        return mapper.updateGraphWorkflowDef(def, latestVersion, json_data);
    }
}
